Generic Cut Actions for External Prolog Predicates

نویسندگان

  • Tiago Soares
  • Ricardo Rocha
  • Michel Ferreira
چکیده

An interesting feature of current Prolog systems is the ability to define external Prolog predicates that can be written in other languages. However, an important drawback of these interfaces is the fact that they lack some important features necessary to improve both the efficiency and the transparent integration of the Prolog system and the external predicates. Such an example is the cut operation. This operation is used quite often in Prolog programs, both for efficiency and semantic preservation. However, its use after an externally defined predicate can have undesired effects. For example, if we have a pending connection to another application, or if we have memory blocks allocated by an external predicate, when a cut operation occurs, we may not be able to perform generic destruct actions, such as closing the pending connection or freeing the unnecessary memory. In this work, we propose an extension of the interface architecture that allows to associate generic user-defined functions with external predicates, in such a way that the Prolog engine transparently executes them when a cut operation occurs. We describe the implementation details of our proposal in the context of the Yap Prolog system.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Declarative Semantics for the Prolog Cut Operator

In practice, a large part of most Prolog programs is in fact functional, the search facilities of Prolog are only rarely needed. In order to arrive at efficient implementations it is then convenient to make use of the cut operator provided by Prolog. Up to now, this operator has been regarded as an extra–logical control operator that destroys the declarative semantics of Prolog. In this paper w...

متن کامل

An Automatic Partial Evaluator for Full Prolog

A partial evaluator for Prolog takes a program and a query and returns a program specialized for all instances of that query. The intention is that the generated program will execute more efficiently than the original one for those instances. This thesis presents “Mixtus”, an automatic partial evaluator for full Prolog, i.e. including non-logical features such as cut, assert, var, write etc. Mi...

متن کامل

Efficient Execution of HiLog in WAM-based Prolog Implementations

In this paper we address the problem of eeciently implementing HiLog, a logic programming language with higher-order syntax and rst-order semantics. In contrast to approaches proposed in the literature that modify, or abandon the WAM framework in order to implement HiLog, our approach to the problem stems from a belief that the WAM should be an adequate abstract machine for the execution of any...

متن کامل

Cardinality Analysis of Prolog

This paper proposes a novel analysis, called cardinality analysis, to approximate the number of solutions to a goal. The analysis is an instantiation of a new abstract interpretation framework for full Prolog (without dynamic predicates) based on sequences of substitutions. The abstract domain captures not only modes and types but also lower and upper bounds on the number of solutions and infor...

متن کامل

A Continuation-Passing Style for Prolog

We propose a translation of Prolog (including cut, if-then-else and similar constructs) into a rst-order continuation-passing style, where (almost) all predicates have one clause and all clauses are binary. The resulting programs can be used as a exible intermediate representation for compilation with a number of advantages as compared to Warren's abstract machine and other proposals. We discus...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2006